<template>
	<view class="mainPage crypt" :style="{'padding-top': `${$store.state.safeArea.top || 0}px`, 'padding-bottom': `${$store.state.safeArea.bottom || 0}px`}">
		<public-head :title="title"></public-head>
		<view class="passwords">
			<u-field v-model="newpsw" label="新密码" placeholder="6-16位字符,支持英文与数字" maxlength="16">
			</u-field>
			<u-field v-model="newpsws" label="确认密码" placeholder="请再次输入新密码" maxlength="16">
			</u-field>
		</view>
		<view>
			<view class="determines" v-if="newpsw&&newpsws" @click="determines">确定</view>
			<view class="determine" v-else>确定</view>
		</view>
	</view>
</template>
<script>
var that
import publicHead from "@/components/publicHead/publicHead.vue"
export default {
	components: {
		publicHead
	},
	data() {
		return {
			title: "设置密码",
			newpsw: '',
			newpsws: '',
			isdetermine: 0,
			verify_code: '',
			timer: null
		}
	},
	onLoad(e) {
		that = this
		that.verify_code = e.verify_code
	},
	methods: {
		determines() {
			console.log('点击1')
			if (that.newpsw.length < 6 || that.newpsw.length > 16) {
				uni.showToast({
					title: '请输入6-16位字符',
					icon: 'none',
					duration: 2000
				});
				console.log('点击2')
			} else if (that.newpsws !== that.newpsw) {
				uni.showToast({
					title: '两次输入的密码不一致',
					icon: 'none',
					duration: 2000
				});
				console.log('点击3')
			} else {
				let data = {
					form_type: 1,
					new_password: that.newpsw,
					repeat_password: that.newpsws,
					verify_code: that.verify_code
				}
				that.$postAjax1('Doctor_doctorForgetPassword', data, function (data) {
					uni.showToast({
						title: '设置成功',
						duration: 2000
					});
					that.timer = setTimeout(() => {
						// 这里添加您的逻辑
						uni.navigateBack({
							delta: 3
						})
					}, 2000)
				})
			}
		},
		toforgetpswd() {
			uni.navigateTo({
				url: 'forgetpswd'
			})
		}
	}
}
</script>
<style scoped lang="scss">
.crypt {
	.determine {
		background: #c4c4c6;
		border-radius: 46rpx;
		margin: 100rpx 60rpx;
		padding: 24rpx 282rpx;
		color: #ffffff;
		font-size: 32rpx;
	}
	.determines {
		background: #ff8f2b;
		box-shadow: 0px 6rpx 8rpx 0px rgba(255, 143, 43, 0.2);
		border-radius: 46rpx;
		margin: 100rpx 60rpx;
		padding: 24rpx 282rpx;
		color: #ffffff;
		font-size: 32rpx;
	}
	.forget {
		position: absolute;
		bottom: 168rpx;
		font-size: 26rpx;
		color: #fe7600;
		text-align: center;
		width: 100%;
	}
}
</style>
